**********************************************
***  Table A13:	Correlation Between Worker Productivity, Attentiveness, and Cognition
**********************************************



use "$dir/Data/analysis_main.dta", clear

eststo clear
eststo: reghdfe blatt blhrprod if pid1==1 & blhrprod_miss==0 , cl(pid) a(roundgroup)
	estadd local samp "Main"
eststo: reghdfe blhiatt blhrprod if pid1==1 & blhrprod_miss==0 , cl(pid) a(roundgroup)
	estadd local samp "Main"

foreach x of varlist avg_numleafr avg_num_stitchesr avg_num_double_holesr{
	egen temp = mean(`x') if day==lastblday, by(pid)
	egen tempbl = max(temp), by(pid)
	eststo: reghdfe tempbl blhrprod if pid1==1 & blhrprod_miss==0 , cl(pid) a(roundgroup)
	estadd local samp "Main"
	drop temp*
}	

label var blhrprod "Hourly production"

#delimit ;
local tablerow blhrprod ;

esttab using "$oa/$t/Table_A13_A.tex", 
	b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles  
	replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
	stats(N, labels("N: workers") fmt(%9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}
	{@{\extracolsep{4pt}}p{4cm}*{10}{>{\centering\arraybackslash}m{2.7cm}}@{}} 
	\toprule 
	\multicolumn{5}{l}{\textbf{PANEL A: Main rounds---Productivity and Attentiveness}}  \bigstrut       \\ \\
	& Attentiveness index & High attentiveness & Number of leaves & Number of stitches & Number of double holes  \\   
	") ;
#delimit cr	




use "$dir/data/analysis_all.dta", clear

keep if round > 15
drop if pid==431		// did not complete CORSI

local k=1
foreach x of varlist n_productivity att_ind hiatt_ind {
	egen temp`k' = mean(`x') if attend==1 & piecerate>0, by(round pid)
	egen bl_`x' = max(temp`k'), by(round pid)
	local `k++'
	drop temp*
}

eststo clear
eststo: reghdfe bl_att_ind bl_n_productivity if pid1==1, cl(pid) a(round)
	estadd local samp "Supp."
eststo: reghdfe bl_hiatt_ind bl_n_productivity if pid1==1, cl(pid) a(round)
	estadd local samp "Supp."
eststo: reghdfe corsi_seq_correct bl_n_productivity if pid1==1, cl(pid) a(round)
	estadd local samp "Supp."
eststo: reghdfe bl_att_ind corsi_seq_correct if pid1==1, cl(pid) a(round)
	estadd local samp "Supp."
eststo: reghdfe bl_hiatt_ind corsi_seq_correct if pid1==1, cl(pid) a(round)
	estadd local samp "Supp."

label var bl_n_productivity "Hourly production"
label var corsi_seq_correct "CORSI performance"

#delimit ;
local tablerow bl_n_productivity corsi_seq_correct ;

esttab using "$oa/$t/Table_A13_B.tex", 
	b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles  
	replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
	stats(N, labels("N: workers") fmt(%9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}
	{@{\extracolsep{4pt}}p{4cm}*{10}{>{\centering\arraybackslash}m{2.7cm}}@{}} 
	\toprule 
	\multicolumn{5}{l}{\textbf{PANEL B: Supplementary rounds---Productivity, Attentiveness, and Cognition}}  \bigstrut       \\ \\
	& Attentiveness index & High attentiveness & CORSI performance & Attentiveness index & High attentiveness  \\   
	") ;
#delimit cr	

